<?php

namespace App\Admin\Model;

class User extends \Frado\DB\Model
{

    public function __construct($scenario = 'default')
    {
        parent::__construct($scenario);
    }

    public function rules(): array
    {
        return [
            ['username,password', 'required'],
        ];
    }

    public static function tableName(): string
    {
        return '{{%user}}';
    }

    public static function findUserByName($username, $field = null)
    {
        $find = static::find();
        if ($field !== null) {
            $find->select($field);
        }
        $find->where('username=:username', [':username' => strtolower($username)]);
        return $find->one();
    }
}